<?php
// <copyright file="AuthenticationType.cs" company="NQtec">
// Copyright (c) 2008, 2009 All Right Reserved, http://www.dqer.com/
// Copyright (c) 2008, 2009 All Right Reserved, http://www.nqtec.com/
//
// This source is part of the DQER library that released under the LGPL.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Victor Gatkov</author>
// <email>v.gatkov@nqtec.com</email>
// <email>info@dqer.com</email>
// <date>2008-09-11</date>
// <summary>Contains a base, abstract class for an AuthorisationPolicyProvider</summary>

   function ucid($cid) {
       global $database;
      $q      = "SELECT * FROM ".TBL_DATA." WHERE `data`='$cid' AND `type`='cid'";
      $result = $database->do_query($q);
      return mysql_numrows($res);
   }

   function create_new_cid($uid) {
       global $database;
       $ts = time();
       do {
        $cid = rand(1010, 9898);
       } while (ucid($cid));
       $q = "INSERT INTO ".TBL_DATA." (`uid`, `data`, `type`, `ts`) VALUES ('$uid', '$cid', 'cid', '$ts')";
       $result = $database->do_query($q);
       return $result;
   }

?>
